<?php
use \Workerman\Autoloader;

require_once __DIR__ . '/../../../../../Workerman/Autoloader.php';
require_once __DIR__.'/../../../Config/Const.php';
Autoloader::setRootPath(__DIR__.'/../../..');

$page_groupId = GROUP_STATISTICS_MNG;
$page_pageId = PAGE_STATISTICS_RESTAURANT_DAY_TURNOVER;

require "../framepages/moudle_base.php";

$date = $_POST['date'];
if (!$date) {
    $date = date('Y-m-d');
}

$order_by = $_POST['order_by'];
if (!$order_by) {
    $order_by = ORDER_BY_DESC;
}


?>
<script type="text/javascript" src="../../src/js/My97DatePicker/WdatePicker.js"> </script>

<div class="main-content">
    <div>
        <table width="100%">
            <form method="post" action="">
                <tr>
                    <th width="13%">日期 &nbsp;<input type="text" name="date" id="date" size="10" onClick="WdatePicker()" readonly="readonly" value="<?php echo $date ?>"></th>
                    <th width="13%">商铺id</th>
                    <th>商铺名称</th>
                    <th>营业额
                        <select name="order_by" id="order_by">
                            <?php
                            if ($order_by == ORDER_BY_DESC) {
                                echo "
                                    <option value='".ORDER_BY_DESC."'>降序排列</option>
                                    <option value='".ORDER_BY_ASC."'>升序排列</option>
                                    ";
                            } else {
                                echo "                                  
                                    <option value='".ORDER_BY_ASC."'>升序排列</option>
                                    <option value='".ORDER_BY_DESC."'>降序排列</option>
                                    ";
                            }
                            ?>

                        </select>
                    </th>
                    <th><input type="submit" class="btn btn-danger" value="查询"></th>
                </tr>

            </form>
            <?php

            $page_index = $_GET['page_index'];
            if (!$page_index) {
                $page_index = 1;
            }
            $every_page_counts = 30;
            $list_start = ($page_index-1)*$every_page_counts;
            $statistics_restaurant_day_turnover_list_array = \Data\Statistics_restaurant_day_turnover_DAO::getListByDate($date,$order_by,$list_start,$every_page_counts);
            $statistics_restaurant_day_turnover_list = $statistics_restaurant_day_turnover_list_array[1];
            $total_count = $statistics_restaurant_day_turnover_list_array[0];
            foreach ($statistics_restaurant_day_turnover_list as $statistics_restaurant_day_turnover_record) {
                $date = $statistics_restaurant_day_turnover_record->getDATE();
                $restaurant_id = $statistics_restaurant_day_turnover_record->getRESTAURANT_ID();
                $restaurant_name = \Data\Restaurant_DAO::getRecordByFields($restaurant_id,RESTAURANT_NAME)[RESTAURANT_NAME];
                $turnover = $statistics_restaurant_day_turnover_record->getTURNOVER();

                echo "
                        <tr>
                            <td>$date</td>                      
                            <td>$restaurant_id</td>
                            <td>$restaurant_name</td>
                            <td>$turnover</td>
                        </tr>
                        ";
            }
            ?>
        </table>
    </div>
    <?php
    require "../framepages/footer.php";
    ?>
</div>
</div>
<script src="../lib/bootstrap/js/bootstrap.js"></script>
</body>
</html>